import java.util.Stack;

/**
 * Created With IntelliJ IDEA
 * Description:牛客网:BM42 用两个栈实现队列
 * <a href="https://www.nowcoder.com/practice/54275ddae22f475981afa2244dd448c6?tpId=295&tqId=23281&ru=/exam/oj&qru=/ta/format-top101/question-ranking&sourceUrl=%2Fexam%2Foj">...</a>
 * User: DELL
 * Data: 2023-03-11
 * Time: 22:26
 */

//题目中保证pop和push均合法,因此不需要进行合法性检验
public class Solution {
    Stack<Integer> stack1 = new Stack<Integer>();
    Stack<Integer> stack2 = new Stack<Integer>();
    //push时只入stack1
    public void push(int node) {
        stack1.push(node);
    }
    //pop时从stack2出
    public int pop() {
        if (stack2.isEmpty()) {
            while (!stack1.isEmpty()) {
                stack2.push(stack1.pop());
            }
        }
        return stack2.pop();
    }
}
